summaryrefslogtreecommitdiff
path: root/app/[lng]/partners/(partners)/pcr/page.tsx
blob: dc639aa8bda65e8f1c00a5db8effdb2c9cbc2574 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { Suspense } from "react"
import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { redirect } from "next/navigation";
import { Shell } from "@/components/shell"
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"
import { InformationButton } from "@/components/information/information-button"

import { PcrTable } from "@/lib/pcr/table/pcr-table";
import { getPcrPoListForPartners } from "@/lib/pcr/service";

export const metadata = {
  title: "PCR 관리",
  description: "Purchase Change Request를 조회하고 관리할 수 있습니다.",
};

async function PartnersPcrTableWrapper() {
  // 세션에서 사용자 정보 확인
  const session = await getServerSession(authOptions);
  if (!session?.user?.id) {
    redirect("/login");
  }

  const vendorId = session.user.companyId || 1;

  // Partners용 데이터 조회 (현재 사용자의 vendorId에 해당하는 데이터만 조회)
  const tableData = await getPcrPoListForPartners({
    page: 1,
    perPage: 10,
    vendorId: vendorId,
  });

  return <PcrTable tableData={tableData} isEvcpPage={false} isPartnersPage={true} currentVendorId={vendorId} />;
}

export default function PartnersPcrPage() {
  return (
    <Shell className="gap-4">
      {/* ═══════════════════════════════════════════════════════════════ */}
      {/* 페이지 헤더 */}
      {/* ═══════════════════════════════════════════════════════════════ */}
      <div className="flex items-center justify-between space-y-2">
        <div className="flex items-center justify-between space-y-2">
          <div>
            <div className="flex items-center gap-2">
              <h2 className="text-2xl font-bold tracking-tight">
                PCR 관리
              </h2>
              <InformationButton pagePath="partners/pcr" />
            </div>
            <p className="text-muted-foreground">
              Purchase Change Request를 조회하고 관리할 수 있습니다. PCR 승인 상태, 변경 구분, PO/계약 정보 등을 확인할 수 있습니다.
            </p>
          </div>
        </div>
      </div>

      {/* ═══════════════════════════════════════════════════════════════ */}
      {/* 메인 테이블 */}
      {/* ═══════════════════════════════════════════════════════════════ */}
      <Suspense
        fallback={
          <DataTableSkeleton
            columnCount={12}
            searchableColumnCount={2}
            filterableColumnCount={3}
            cellWidths={["8rem", "8rem", "12rem", "12rem", "10rem", "12rem"]}
            shrinkZero
          />
        }
      >
        <PartnersPcrTableWrapper />
      </Suspense>
    </Shell>
  );
}